package Operation;

import Book.BookList;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 石方旭
 * Date: 2022-04-13
 * Time: 12:29
 */
public class BorrowOperation implements IOperation {

    @Override
    public void work(BookList book) {
        System.out.println("借阅图书");
        System.out.println("请输入你要借阅的书籍");
        Scanner scan = new Scanner(System.in);
        String name = scan.nextLine();
        int i =0;
        for(i =0;i< book.getUsedSize();++i) {
            if(book.getPos(i).bookName.equals(name)) {
                System.out.println("查找成功~~~~-》"+"书籍信息如下所示：");
                System.out.println(book.getPos(i));
                if(!book.getPos(i).isBorrow) {
                    System.out.println("书籍未借出~~~~可以借阅");
                    book.getPos(i).isBorrow=true;
                    System.out.println("书籍借出成功");
                } else {
                    System.out.println("书籍已经借出");
                }
                return;
            }
        }
        if(i== book.getUsedSize()) {
            System.out.println("没有该书籍");
        }
    }
}
